/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bio.jpa.session;

import com.bio.jpa.entities.GenBank;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import com.bio.jpa.entities.Project;
import com.bio.jpa.entities.User;
import java.util.List;

/**
 *
 * @author Diego
 */
@Stateless
public class ProjectFacade extends AbstractFacade<Project> {

    @PersistenceContext(unitName = "BioDeskPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public ProjectFacade() {
        super(Project.class);
    }

    public List<User> findUsersNotInProject(Integer id) {
        javax.persistence.Query q = getEntityManager().createNamedQuery("User.findUsersNotInProject");
        q.setParameter("prjId", id);
        List<User> u = q.getResultList();
        return u;
    }

    public List<User> findMyUsers(Integer id) {
        javax.persistence.Query q = getEntityManager().createNamedQuery("Project.findMyUsers");
        q.setParameter("prjId", id);
        List<User> u = q.getResultList();
        return u;
    }
    public List<GenBank> findMyGb(Integer id) {
        javax.persistence.Query q = getEntityManager().createNamedQuery("Project.findMyGb");
        q.setParameter("prjId", id);
        List<GenBank> u = q.getResultList();
        return u;
    }

}
